﻿@model DateTime
@*@Html.EditorFor(m => m.BirthDate, new { PreviousYearCount = 10, NextYearCount = 10 })*@
@{
    List<SelectListItem> days = new List<SelectListItem>();
    for (int i = 1; i <= 31; i++)
    {
        days.Add(new SelectListItem() { Text = i.ToString(), Value = i.ToString(), Selected = (i == Model.Day ? true : false) });
    }

    List<SelectListItem> months = new List<SelectListItem>();
    for (int i = 1; i <= 12; i++)
    {
        months.Add(new SelectListItem() { Text = i.ToString(), Value = i.ToString(), Selected = (i == Model.Month ? true : false) });
    }

    List<SelectListItem> years = new List<SelectListItem>();

    int prevYearCount = ViewBag.PreviousYearCount ?? 20;
    int nextYearCount = ViewBag.NextYearCount ?? 0;
    int year = Model.Year <= 1 ? DateTime.Now.Year : Model.Year;

    for (int i = year - prevYearCount; i <= year + nextYearCount; i++)
    {
        years.Add(new SelectListItem() { Text = i.ToString(), Value = i.ToString(), Selected = (i == year ? true : false) });
    }
}

@Html.DropDownList("days", days)
@Html.DropDownList("months", months)
@Html.DropDownList("years", years)